package com.jt.chapter06.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author jiang tao
 * @date 2022/1/24
 * @description:
 **/
@Configuration
public class CorConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins("*")
                //允许cookie跨域
                .allowedHeaders("*")
                .allowedMethods("*")
//                .allowedHeaders("*")
//                .maxAge(1800L)
                .allowCredentials(true);
    }
}
